<html>
<head>
    <meta name="_token" content="{{csrf_token()}}"/>
    <meta name="viewport" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
    <script src="mail/clipboard.min.js"></script>
    <script src="mail/jquery-2.0.3.min.js"></script>
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, "Segoe UI",
            Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
            font-size: 16px;
        }
        .btn {
            display: block;
            border-radius: 3px;
            line-height: 16px;
        }
        .mail {
            display: inline-block;
            margin: 5px;
            padding: 5px;
        }
        .password {
            display: inline-block;
            margin: 5px;
            padding: 5px;
        }
        .red {
            background-color: slategray;
        }

        .account-block {
            width: 414px;
        }
    </style>
</head>

<body>
<div class="filter">
    <label for="filter">筛选</label>
    <select id="filter" name="filter" style="font-size: 16px;">
        <option value="0" @if($filter==0) selected @endif>所有</option>
        <option value="1" @if($filter==1) selected @endif>SSR</option>
        <option value="2" @if($filter==2) selected @endif>未使用</option>
    </select>
    (总计: {{$count}})
</div>

@foreach($mails as $mail)
    <div class="account-block account-block-{{$mail->id}} @if($mail->used == 1) red @endif">
        <div data-id="{{$mail->id}}" class=" mail" data-clipboard-text="{{$mail->account}}">
            <a class="btn">{{$mail->account}}</a>
        </div>
        <div class=" password" data-clipboard-text="{{$mail->password}}">
            <a class="btn">{{$mail->password}}</a>
        </div>
    </div>
@endforeach


<script>
  new Clipboard('.js-copy');
  new Clipboard('.mail');
  new Clipboard('.password');

  $(function () {
    $('.mail').click(function () {
      var id = $(this).data('id');
      $.post("update_used", {id: id, _token: $("meta[name='_token']").attr("content")});
      $('.account-block-'+id).addClass('red');
    });

    $('#filter').change(function () {
      var filter = $(this).val();
      window.location.href = 'm?filter=' + filter;
    });

    $('.mark_ssr').click(function () {
      var id = $(this).data('id');
      $.post('mark_ssr', {id: id, _token: $("meta[name='_token']").attr("content")});
    });
  });
</script>

</body>

<script>

</script>
</html>